<?php
/**
 * Created by 1971599474@qq.com
 * User: zhixuan
 * Date: 2020/1/17
 * Time: 14:11
 */

namespace app\index\controller;


use app\common\controller\BaseController;
use app\common\model\AdvPosition;
use app\common\model\Category;
use think\App;

class Base extends BaseController
{

    public $return = ['code'=>300,'msg'=>'','data'=>[]];
    public $member = 0;
    public $member_id = 0;
    public function initialize(){
        parent::initialize();

        $category = $this->getCategory();
        $this->assign('category',$category);
        $top_ad = AdvPosition::getAdvByPosition(1);
        $this->assign('top_ad',$top_ad);
        $this->member = session('memberInfo');
        $this->member_id = session('member_id');
        $this->assign('member_id',$this->member_id);
        $this->assign('member',$this->member);

        $config_base = tpCache('basic');
        $config_search = tpCache('index_search');
        $config_search['hot_search'] = explode(PHP_EOL,$config_search['hot_search']);
        $this->assign(compact('config_base','config_search'));
    }

    /*
     * 获取分类
     * */
    public function getCategory(){
        return Category::getAllCategory();
    }
}
